/**
 * Created by kevin on 2017/01/08.
 *
 * 视频页面
 * 全屏播放
 * 自动播放，微信ios可以，安卓还不行，只能在加载完毕后马上播放，即只能在一开始就放视频的案例中使用
 */


var eosi = window.eosi || {};
this.eosi.website = this.eosi.website || {};

(function (window) {
    // the application


    function VideoPage(config) {

        this.Container_constructor();
        this.config = config;
        //console.log(this.config)
        this.init();
        //console.log(this.father.targetWidth);

    }


    var p = createjs.extend(VideoPage, eosi.website.BasePage);
    p.className = "VideoPage";


    /*
     * 加载资源
     * */
    p.loadRes = function(){
        //alert(typeof AUTO_VIDEO);
        if(AUTO_VIDEO == ""){
            alert("视频没有设置!");
            //return;
        }else{
            this.resItems = [];
            this.loader = new createjs.LoadQueue(true);
            this.loader.on("complete", this.loadComplete, this);
            this.loader.on("fileload", this.onLoaded, this);
            this.loader.on("progress", this.onProgress, this);
            //console.log(AUTO_VIDEO)
            this.loader.loadManifest([AUTO_VIDEO], true, "./");
        }


    }
    /*
    *绘制页面
    * */
    p.drawPage = function(){

        //console.log('aaaa');
        //document.write("<script src='libs/VideoAutoplay.js'><\/script>");
        //document.write("<script src='libs/jweixin-1.0.0.js'><\/script>");
        //this.createDOMElementVideo();
        var idRef = "container";
        var lParent = document.getElementById(idRef);
        if (!lParent) {
            var lMesg = "没有元素 [" + idRef + "] ";
            alert(lMesg);
            return null;
        }
        var video = document.getElementById("video")
        //console.log(this.loader.getResult("clayer_page3_video"))
        video.setAttribute("src",this.loader.getResult(AUTO_VIDEO.id).src);
        var viceoHolder = document.getElementById("videobox");
        viceoHolder.style.display = 'block';
        VIDEO_LOADED = true;
        //this.setAction();


        /*var videojs = document.createElement("script");

        videojs.src = "libs/VideoAutoplay.js";
        lParent.appendChild(videojs);*/
        this.isDraw = true;

    }





    // add MyApp to myNameSpace
    window.eosi.website.VideoPage = createjs.promote(VideoPage, "eosi.website.BasePage");
//}());
}(window));





